package it.xiuxian.homepage.presenter

import com.lzy.okgo.OkGo
import it.xiuxian.homepage.activity.WorkActivity
import it.xiuxian.homepage.bean.WorkBean

import it.xiuxian.lib.base.BaseBean
import it.xiuxian.lib.base.BasePresenter
import it.xiuxian.lib.base.ILoadBind
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig
import java.util.*

class WorkActivityPresenter:BasePresenter<WorkActivity>(){
    fun getList(){
        OkGo.post<BaseBean<WorkBean>>(HttpConfig.BASE_URL+"/apprenwu/get")
            .execute(object : CallBackOption<BaseBean<WorkBean>>() {}.loadBind(mView as WorkActivity).execute(
                object : ILoadBind<BaseBean<WorkBean>> {
                    override fun excute(bean: BaseBean<WorkBean>){
                        if(bean.code==0){
                             var newlist = ArrayList<WorkBean>()
                            newlist.add(bean.data)
                            //(mView as WorkActivity).setUI(newlist)
                            (mView as WorkActivity).setUI(bean.data)
                        }
                    }
                }
            ))
    }
    fun submit(){
        OkGo.post<BaseBean<String>>(HttpConfig.BASE_URL+"/apprenwu/tijiao")
            .execute(object : CallBackOption<BaseBean<String>>() {}.loadBind(mView as WorkActivity).execute(
                object : ILoadBind<BaseBean<String>> {
                    override fun excute(bean: BaseBean<String>) {
                        if(bean.code==0){
                            (mView as WorkActivity).updateUI(bean.msg)
                        }
                    }
                }
            ))
    }
}